package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchEnergyConsumptionStats;
import com.ruoyi.system.service.IDispatchEnergyConsumptionStatsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 能耗统计结果Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchEnergyConsumptionStats")
public class DispatchEnergyConsumptionStatsController extends BaseController
{
    @Autowired
    private IDispatchEnergyConsumptionStatsService dispatchEnergyConsumptionStatsService;

    /**
     * 查询能耗统计结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchEnergyConsumptionStats:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchEnergyConsumptionStats dispatchEnergyConsumptionStats)
    {
        startPage();
        List<DispatchEnergyConsumptionStats> list = dispatchEnergyConsumptionStatsService.selectDispatchEnergyConsumptionStatsList(dispatchEnergyConsumptionStats);
        return getDataTable(list);
    }

    /**
     * 导出能耗统计结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchEnergyConsumptionStats:export')")
    @Log(title = "能耗统计结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchEnergyConsumptionStats dispatchEnergyConsumptionStats)
    {
        List<DispatchEnergyConsumptionStats> list = dispatchEnergyConsumptionStatsService.selectDispatchEnergyConsumptionStatsList(dispatchEnergyConsumptionStats);
        ExcelUtil<DispatchEnergyConsumptionStats> util = new ExcelUtil<DispatchEnergyConsumptionStats>(DispatchEnergyConsumptionStats.class);
        util.exportExcel(response, list, "能耗统计结果数据");
    }

    /**
     * 获取能耗统计结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchEnergyConsumptionStats:query')")
    @GetMapping(value = "/{energyConsumptionStatsId}")
    public AjaxResult getInfo(@PathVariable("energyConsumptionStatsId") Long energyConsumptionStatsId)
    {
        return success(dispatchEnergyConsumptionStatsService.selectDispatchEnergyConsumptionStatsByEnergyConsumptionStatsId(energyConsumptionStatsId));
    }

    /**
     * 新增能耗统计结果
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchEnergyConsumptionStats:add')")
    @Log(title = "能耗统计结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchEnergyConsumptionStats dispatchEnergyConsumptionStats)
    {
        return toAjax(dispatchEnergyConsumptionStatsService.insertDispatchEnergyConsumptionStats(dispatchEnergyConsumptionStats));
    }

    /**
     * 修改能耗统计结果
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchEnergyConsumptionStats:edit')")
    @Log(title = "能耗统计结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchEnergyConsumptionStats dispatchEnergyConsumptionStats)
    {
        return toAjax(dispatchEnergyConsumptionStatsService.updateDispatchEnergyConsumptionStats(dispatchEnergyConsumptionStats));
    }

    /**
     * 删除能耗统计结果
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchEnergyConsumptionStats:remove')")
    @Log(title = "能耗统计结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{energyConsumptionStatsIds}")
    public AjaxResult remove(@PathVariable Long[] energyConsumptionStatsIds)
    {
        return toAjax(dispatchEnergyConsumptionStatsService.deleteDispatchEnergyConsumptionStatsByEnergyConsumptionStatsIds(energyConsumptionStatsIds));
    }
}
